package com.czy.workflow.core.service.impl;

import com.czy.workflow.core.model.*;
import com.czy.workflow.core.service.FlowService;
import com.czy.workflow.core.service.dao.BranchRepository;
import com.czy.workflow.core.service.dao.MainRepository;
import com.czy.workflow.core.service.dao.NodeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by admin on 2019/8/31.
 */


@Service("mysqlFlowService")
public class MysqlFlowService implements FlowService {

    @Autowired MainRepository mainRepository;

    @Autowired NodeRepository nodeRepository;

    @Autowired BranchRepository branchRepository;

    @Override
    public boolean saveFlowMain(FlowMain flowMain) {
        return false;
    }

    @Override
    public FlowMain getFlowMainById(String flowId) {
        return mainRepository.findById(flowId).orElse(null);
    }

    @Override
    public FlowNode getFlowNodeById(String flowId, String nodeId) {
        return nodeRepository.findById(nodeId).orElse(null);
    }

    @Override
    public List<FlowNode> getNextNodes(String flowId, String nodeId) {
        return nodeRepository.findNextNodes(nodeId);
    }

    @Override
    public List<FlowBranch> getNodeBranches(String flowId, String nodeId){
        return branchRepository.findNoteBranches(nodeId);
    }

    @Override
    public List<FlowNode> getStartNodes(String flowId) {
        return null;
    }

    @Override
    public boolean refreshCurrentNodes(String flowId, String taskId, List<FlowNode> nodes) {
        return false;
    }

    @Override
    public boolean clearCurrentNodes(String flowId, String taskId) {
        return false;
    }

    @Override
    public List<FlowNode> getCurrentNodes(String flowId, String taskId) {
        return null;
    }

    @Override
    public boolean saveFlowLog(TaskInfo taskInfo, boolean result) {
        return true;
    }
}
